package db;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import model.Bill;

public class DbBill {
	private Connection con;
	
	public int insert(Bill bill) throws Exception {
		 //call to get the next ssn number
	    

	   int rc = -1;
	   String query="INSERT INTO Bill(amount)  VALUES('"+
	  		
	  		bill.getAmount() + "')";
	        
	        
	                 

	   System.out.println("insert : " + query);
	  try{ // insert new employee +  dependent
	      Statement stmt = con.createStatement();
	      stmt.setQueryTimeout(5);
	 	  rc = stmt.executeUpdate(query);
	      stmt.close();
	  }//end try
	   catch(SQLException ex){
	      System.out.println("Order ikke oprettet");
	      System.out.println("SQLException says: " + ex.getMessage());
	     throw new Exception ("Order is not inserted correct");
	   }
	   return(rc);
	}

}
